package org.finesys.system.convert;

import java.util.List;

import org.finesys.system.api.dto.DeptDTO;
import org.finesys.system.api.entity.SysDept;
import org.finesys.system.api.vo.DeptExcelVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface SysDeptConvert {

    SysDeptConvert INSTANCE = Mappers.getMapper(SysDeptConvert.class);

    /**
     * 转换AppDto为SysApp对象
     */
    @Mappings({
            @Mapping(target = "delFlag", ignore = true)

    })
    SysDept convert(DeptDTO deptDTO);

    /**
     * 转换SysApp为AppDto对象
     */
    @Mappings({
            @Mapping(target = "children", ignore = true)

    })
    DeptDTO convert(SysDept sysDept);

    /**
     * 转换SysApp为AppDto对象
     */
    @Mappings({
            @Mapping(target = "lineNum", ignore = true),
            @Mapping(target = "parentName", ignore = true),
    })
    DeptExcelVO convertExcelVO(SysDept sysDept);

    /**
     * 数组转换
     */
    List<DeptDTO> convertList(List<SysDept> list);

    /**
     * 分页对象转换
     */

    @Mappings({
            @Mapping(target = "optimizeJoinOfCountSql", ignore = true)
    })
    Page<DeptDTO> convertPage(Page<SysDept> appDO);


}
